﻿<phone:PhoneApplicationPage 
    x:Class="ActivityTracker.Monthly_TimeSpentPieChart"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:phone="clr-namespace:Microsoft.Phone.Controls;assembly=Microsoft.Phone"
    xmlns:shell="clr-namespace:Microsoft.Phone.Shell;assembly=Microsoft.Phone"
    xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
    xmlns:charting="clr-namespace:System.Windows.Controls.DataVisualization.Charting;assembly=System.Windows.Controls.DataVisualization.Toolkit"
    xmlns:toolkit="clr-namespace:Microsoft.Phone.Controls;assembly=Microsoft.Phone.Controls.Toolkit"
    xmlns:customControls="clr-namespace:CustomControls;assembly=PieChartCustomControl"
    Loaded="PhoneApplicationPage_Loaded"
    FontFamily="{StaticResource PhoneFontFamilyNormal}"
    FontSize="{StaticResource PhoneFontSizeNormal}"
    Foreground="{StaticResource PhoneForegroundBrush}"
    SupportedOrientations="Portrait" Orientation="Portrait"
    mc:Ignorable="d" d:DesignHeight="728" d:DesignWidth="480"
    shell:SystemTray.IsVisible="False">

    <phone:PhoneApplicationPage.Resources>
        <Style TargetType="customControls:PieChartLabel" x:Key="pieChartLabelStyle">
            <Setter Property="LineStrokeThickness" Value="2"/>
            <Setter Property="LineStroke" Value="Black"/>
            <Setter Property="Template">
                <Setter.Value>
                    <ControlTemplate TargetType="customControls:PieChartLabel">
                        <Canvas Name="Panel_PART">
                            <Polyline Name="Polyline_PART" StrokeThickness="{TemplateBinding LineStrokeThickness}" Stroke="{TemplateBinding LineStroke}" StrokeLineJoin="Round" />
                            <StackPanel Background="#00ABA9" Name="Content_PART">
                                <Border BorderThickness="1" BorderBrush="Gray">
                                    <StackPanel Background="{StaticResource PhoneAccentBrush}" Orientation="Horizontal">
                                        <TextBlock Text="{Binding ActName}" Foreground="{StaticResource PhoneForegroundBrush}" Margin="0,0,5,0" FontSize="24"/>
                                    </StackPanel>
                                </Border>
                            </StackPanel>
                        </Canvas>
                    </ControlTemplate>
                </Setter.Value>
            </Setter>
        </Style>
        <DataTemplate x:Key="Details">
            <Grid>
                <Grid.ColumnDefinitions>
                    <ColumnDefinition Width="Auto"/>
                    <ColumnDefinition Width="*"/>
                </Grid.ColumnDefinitions>
                <Grid.RowDefinitions>
                    <RowDefinition />
                    <RowDefinition />
                </Grid.RowDefinitions>
                <TextBlock Text="Name: " Grid.Column="0" Grid.Row="0" Style="{StaticResource PhoneTextTitle3Style}"/>
                <TextBlock Text="{Binding ActName}" Grid.Column="1" Grid.Row="0" Style="{StaticResource PhoneTextTitle3Style}"/>
                <TextBlock Text="Duration: " Grid.Column="0" Grid.Row="1" Style="{StaticResource PhoneTextTitle3Style}"/>
                <TextBlock Text="{Binding ActDur}" Grid.Column="1" Grid.Row="1" Style="{StaticResource PhoneTextTitle3Style}"/>
            </Grid>
        </DataTemplate>
    </phone:PhoneApplicationPage.Resources>

    <!--LayoutRoot is the root grid where all page content is placed-->
    <Grid x:Name="LayoutRoot" Background="{StaticResource bipivot}">
        <Grid.RowDefinitions>
            <RowDefinition Height="Auto"/>
            <RowDefinition Height="*"/>
        </Grid.RowDefinitions>

        <!--TitlePanel contains the name of the application and page title-->
        <StackPanel x:Name="TitlePanel" Grid.Row="0" >
            <TextBlock x:Name="ApplicationTitle" Foreground="White" Text="ACTIVITY TRACKER - GROUPED BY ACTIVITY" TextWrapping="Wrap" Style="{StaticResource PhoneTextNormalStyle}"/>
        </StackPanel>

        <!--ContentPanel - place additional content here-->
        <Grid x:Name="ContentPanel" Grid.Row="1">
            <Grid.RowDefinitions>
                <RowDefinition Height="Auto"/>
                <RowDefinition Height="Auto"/>
                <RowDefinition Height="*"/>
            </Grid.RowDefinitions>
            <StackPanel x:Name="stkpnllistpkr" Orientation="Horizontal" Grid.Row="0">
                <toolkit:ListPicker Foreground="White" Height="48" HorizontalAlignment="Left" x:Name="lpicMonth" VerticalAlignment="Top" Width="170" Margin="10,10,0,0">
                    <toolkit:ListPicker.ItemTemplate>
                        <DataTemplate>
                            <StackPanel>
                                <TextBlock Text="{Binding}" Foreground="White" FontSize="26" Margin="10, 6, 0, 8" />
                            </StackPanel>
                        </DataTemplate>
                    </toolkit:ListPicker.ItemTemplate>
                </toolkit:ListPicker>
                <toolkit:ListPicker Height="48" Foreground="White" x:Name="lpicYear"  VerticalAlignment="Top" Width="170" Margin="10,10,0,0" HorizontalAlignment="Center" >
                    <toolkit:ListPicker.ItemTemplate>
                        <DataTemplate>
                            <StackPanel>
                                <TextBlock Text="{Binding}" Foreground="White" FontSize="26" Margin="10, 6, 0, 8" />
                            </StackPanel>
                        </DataTemplate>
                    </toolkit:ListPicker.ItemTemplate>
                </toolkit:ListPicker>
                <StackPanel x:Name="stkpnl" Orientation="Vertical"  Width="100" HorizontalAlignment="Right"  VerticalAlignment="Top">
                    <Button x:Name="btnok" Foreground="White" Content="OK" Width="100" HorizontalAlignment="Right" VerticalAlignment="Top" Click="btnok_Click" Margin="10, 6, 0, 8"></Button>
                </StackPanel>
            </StackPanel>
            <StackPanel Grid.Row="1">
                <ContentControl ContentTemplate="{StaticResource Details}" HorizontalAlignment="Left" x:Name="DetailsControl" Margin="2,5,2,5"/>
            </StackPanel>
            <StackPanel x:Name="stkpnlpiechart" Grid.Row="2" >
                <customControls:LabeledPieChart x:Name="PieChart" Height="510" Width="510" Margin="-6,10,0,0">
                    <customControls:LabeledPieChart.Series>
                        <customControls:LabeledPieSeries x:Name="labeledPieSeries" ItemsSource="{Binding}" IndependentValuePath="ActName" DependentValuePath="ActDur" IsSelectionEnabled="True" PieChartLabelStyle="{StaticResource pieChartLabelStyle}" LabelDisplayMode="AutoMixed" SelectionChanged="labeledPieSeries_SelectionChanged"/>
                    </customControls:LabeledPieChart.Series>
                </customControls:LabeledPieChart>
            </StackPanel>
            <TextBlock Grid.Row="2" VerticalAlignment="Center" Foreground="White" HorizontalAlignment="Center" x:Name="txtblkResult" Text="Data not available for this month" Visibility="Collapsed"/>

        </Grid>
    </Grid>

    <!--Sample code showing usage of ApplicationBar-->
    <phone:PhoneApplicationPage.ApplicationBar >
        <shell:ApplicationBar IsVisible="True" IsMenuEnabled="True">
            <shell:ApplicationBarIconButton IconUri="/Images/barchart.png" Text="bar chart" Click="btnBarChart_Click" />
            <shell:ApplicationBar.MenuItems>
                <shell:ApplicationBarMenuItem Text="Group By Category" Click="ApplicationBarMenuItem_Click">
                </shell:ApplicationBarMenuItem>
            </shell:ApplicationBar.MenuItems>
        </shell:ApplicationBar>
    </phone:PhoneApplicationPage.ApplicationBar>

</phone:PhoneApplicationPage>
